﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="news.aspx.cs" Inherits="UI.system.news" %>
<%@ Import Namespace="Model" %>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
<link href="css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="lib/zTree/v3/css/zTreeStyle/zTreeStyle.css" type="text/css">
<!--[if IE 6]>
<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>资讯列表</title>
</head>
<body class="pos-r">
<div>
	<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 资讯管理 <span class="c-gray en">&gt;</span> 资讯列表 
    <%if (typeid != 0){ %><span class="c-gray en">&gt;</span> <font style="color:red"></font><%} %>
    <a class="btn btn-success radius r mr-20" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
	<div class="pd-20">
		<div class="text-c"> 日期范围：
			<input type="text" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'begindate\')||\'%y-%M-%d\'}'})" id="begindate" value="<%=begindate %>" class="input-text Wdate" style="width:120px;">
			-
			<input type="text" onfocus="WdatePicker({minDate:'#F{$dp.$D(\'enddate\')}',maxDate:'%y-%M-%d'})" id="enddate" value="<%=enddate %>" class="input-text Wdate" style="width:120px;">
			<input type="text" name="" id="keyword" placeholder="资讯名称" style="width:250px" class="input-text" value="<%=keyword %>">
			<button name="" id="search" class="btn btn-success" type="submit"><i class="Hui-iconfont">&#xe665;</i> 搜资讯</button>
		</div>
		<div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"><a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a> <a class="btn btn-primary radius" onclick="news_add('添加资讯','addnews.aspx?type=<%=typeid %>')" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 添加资讯</a></span> <span class="r">共有数据：<strong><%=count %></strong> 条</span> </div>
		<div class="mt-20">
			<table class="table table-border table-bordered table-bg table-hover table-sort">
				<thead>
					<tr class="text-c">
						<th width="40"><input name="" type="checkbox" value=""></th>
						<th width="100">资讯名称</th>
						<th width="100">点击量</th>
                        <th width="40">创建时间</th>
						<th width="100">操作</th>
					</tr>
				</thead>
				<tbody>
                    <asp:Repeater ID="Repeater1" runat="server">
                    <ItemTemplate>
					<tr class="text-c va-m">
						<td><input name="" type="checkbox" value='<%#Eval("id") %>'></td>
						<td class="text-l"><%#Eval("name")%></td>
                        <td class="text-l"><%#Eval("click")%></td>
                        <td class="text-l"><%#Eval("createdate")%></td>
                        <td>
                        <a style="text-decoration:none" class="ml-5" onClick=news_add('编辑资讯','addnews.aspx?id=<%#Eval("id") %>') href="javascript:;" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a> <a style="text-decoration:none" class="ml-5" onClick=product_del(this,'<%#Eval("id") %>') href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a></td>
					</tr>
                    </ItemTemplate>
                    </asp:Repeater>
				</tbody>
			</table>
            <div id="pager"></div>
		</div>
	</div>
</div>
<iframe id="iframe" src="" style="display:none;"></iframe>
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="lib/layer/1.9.3/layer.js"></script>
<script type="text/javascript" src="lib/My97DatePicker/WdatePicker.js"></script> 
<script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script> 
<script type="text/javascript" src="js/H-ui.js"></script> 
<script type="text/javascript" src="js/H-ui.admin.js"></script> 
<script type="text/javascript">
    var setting = {
        view: {
            dblClickExpand: false,
            showLine: false,
            selectedMulti: false
        },
        data: {
            simpleData: {
                enable: true,
                idKey: "id",
                pIdKey: "pId",
                rootPId: ""
            }
        },
        callback: {
            beforeClick: function (treeId, treeNode) {
                var zTree = $.fn.zTree.getZTreeObj("tree");
                if (treeNode.isParent) {
                    window.location.href = "product.aspx?type=" + treeNode.id + "&name="+treeNode.name;
                    //zTree.expandNode(treeNode);
                    //return true;
                } else {
                    window.location.href = "product.aspx?type=" + treeNode.id + "&name=" + treeNode.name;
                    //return true;
                }
            }
        }
    };



    var code;

    function showCode(str) {
        if (!code) code = $("#code");
        code.empty();
        code.append("<li>" + str + "</li>");
    }

    $(document).ready(function () {
        var data = {};
        data.act = "Find_AllProductType";
        Ajax.Post("/admin/tools/Admin.ashx", data, function (r) {
            var str = "zNodes=[";
            var json = $.parseJSON(r);
            $.each(json.data, function (i, info) {
                str += "{id:" + info.id + ",pId:" + info.parentid + ",name:'" + info.name + "',open:true},";
            });
            str += "]";
            eval(str);
            var t = $("#treeDemo");
            t = $.fn.zTree.init(t, setting, zNodes);
            demoIframe = $("#testIframe");
            demoIframe.bind("load", loadReady);
            var zTree = $.fn.zTree.getZTreeObj("tree");
            zTree.selectNode(zTree.getNodeByParam("id", '2'));
        });
    });


    /*图片-添加*/
    function news_add(title, url) {
        var index = layer.open({
            type: 2,
            title: title,
            content: url
        });
        layer.full(index);
    }
    /*图片-查看*/
    function product_show(title, url, id) {
        var index = layer.open({
            type: 2,
            title: title,
            content: url
        });
        layer.full(index);
    }
    /*图片-审核*/
    function product_shenhe(obj, id) {
        layer.confirm('审核文章？', {
            btn: ['通过', '不通过'],
            shade: false
        },
	function () {
	    $(obj).parents("tr").find(".td-manage").prepend('<a class="c-primary" onClick="product_start(this,id)" href="javascript:;" title="申请上线">申请上线</a>');
	    $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已发布</span>');
	    $(obj).remove();
	    layer.msg('已发布', { icon: 6, time: 1000 });
	},
	function () {
	    $(obj).parents("tr").find(".td-manage").prepend('<a class="c-primary" onClick="product_shenqing(this,id)" href="javascript:;" title="申请上线">申请上线</a>');
	    $(obj).parents("tr").find(".td-status").html('<span class="label label-danger radius">未通过</span>');
	    $(obj).remove();
	    layer.msg('未通过', { icon: 5, time: 1000 });
	});
    }
    /*图片-下架*/
    function product_down(obj, id) {
        layer.confirm('确认要下架吗？', function (index) {
            var data = {};
            data.act = "Product_State";
            data.id = id;
            data.state = 0;
            Ajax.Post("/admin/tools/Admin.ashx", data, function (r) {
                $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="product_up(this,'+id+')" href="javascript:;" title="发布"><i class="Hui-iconfont">&#xe603;</i></a>');
                $(obj).parents("tr").find(".td-status").html('<span class="label label-defaunt radius">已下架</span>');
                $(obj).remove();
                layer.msg('已下架!', { icon: 5, time: 1000 });
            });
        });
    }

    /*图片-发布*/
    function product_up(obj, id) {
        layer.confirm('确认要发布吗？', function (index) {
            var data = {};
            data.act = "Product_State";
            data.id = id;
            data.state = 1;
            Ajax.Post("/admin/tools/Admin.ashx", data, function (r) {
                $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="product_down(this,'+id+')" href="javascript:;" title="下架"><i class="Hui-iconfont">&#xe6de;</i></a>');
                $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已发布</span>');
                $(obj).remove();
                layer.msg('已发布!', { icon: 6, time: 1000 });
            });
        });
    }
    /*图片-申请上线*/
    function product_shenqing(obj, id) {
        $(obj).parents("tr").find(".td-status").html('<span class="label label-default radius">待审核</span>');
        $(obj).parents("tr").find(".td-manage").html("");
        layer.msg('已提交申请，耐心等待审核!', { icon: 1, time: 2000 });
    }
    /*图片-编辑*/
    function product_edit(title, url, id) {
        var index = layer.open({
            type: 2,
            title: title,
            content: url
        });
        layer.full(index);
    }
    /*图片-删除*/
    function product_del(obj, id) {
        layer.confirm('确认要删除吗？', function (index) {
            var data = {};
            data.act = "Delete_News";
            data.ids = id;
            Ajax.Post("/system/tools/Admin.ashx", data, function (r) {
                var json = $.parseJSON(r);
                if (json.state) {
                    layer.msg('已删除!', { icon: 1, time: 1000 });
                    $("#iframe").attr("src", "/system/make.aspx?flag=all");
                    var index = parent.layer.getFrameIndex(window.name);
                    $('.btn-success').click();
                }
            });
        });
    }
    function change_sort(o,id) {
        var data = {};
        data.act = "Change_ProductSort";
        data.id = id;
        data.sort = $(o).val();
        Ajax.Post("/admin/tools/Admin.ashx", data, function (r) {
            
        });
    };
    function datadel() {
        var ids = new Array();
        $(".table tr:gt(0) input:checked").each(function () {
            ids.push($(this).val());
        });
        if (ids.length == 0) {
            alert("请选择要删除的资讯");
            return;
        }
        layer.confirm('确认要批量删除吗？', function (index) {
            var data = {};
            data.act = "Delete_News";
            data.ids = ids + "";
            Ajax.Post("/system/tools/Admin.ashx", data, function (r) {
                var json = $.parseJSON(r);
                if (json.state) {
                    layer.msg('已删除!', { icon: 1, time: 1000 });
                    $("#iframe").attr("src","/system/make.aspx?flag=all");
                    var index = parent.layer.getFrameIndex(window.name);
                    $('.btn-success').click();
                }
            });
        });
    }
    var count = parseInt("<%=count %>");
    var pageindex = parseInt("<%=pageindex %>");
    var name = '<%=Request["name"] %>';
    Pager.Init(pageindex, 20, count, function (i) {
        var keyword = $("#keyword").val();
        var begindate = $("#begindate").val();
        var enddate = $("#enddate").val();
        var typeid = $("#type").val();
        window.location.href = "news.aspx?pageindex=" + i + "&keyword=" + keyword + "&begindate=" + begindate + "&enddate=" + enddate + "&typeid=" + typeid + "&name=" + name;
    });

    $("#search").click(function () {
        var keyword = $("#keyword").val();
        var begindate = $("#begindate").val();
        var enddate = $("#enddate").val();
        var typeid = $("#type").val();
        window.location.href = "news.aspx?keyword=" + keyword + "&begindate=" + begindate + "&enddate=" + enddate + "&typeid=" + typeid + "&name=" + name;
    });
</script>
</body>
</html>
